<template>
	<view class="wrap">
		<!-- <u-button @click="clear">清空列表</u-button> -->
		<u-button @click="soldshop">上架商品</u-button>
		
				<view class="demo-warter" v-for="(item, index) in list" :key="item.orderDetailId">
					<!-- 警告：微信小程序中需要hx2.8.11版本才支持在template中结合其他组件，比如下方的lazy-load组件 -->
					<view class="a1_four" @click="skipDetail(item.orderDetailId)">
						<!-- <view v-for="(itemone,index) in item.fileList"> -->
							<u-lazy-load threshold="-450" border-radius="10" :image="item.fileList[0].pictureUrl" :index="index"></u-lazy-load> 
						<!-- </view> -->
						<view class="demo-title">
							{{item.orderDetailName}}
						</view>
						<view class="demo-price">
							{{item.orderDetailPrice}}元/{{item.orderDetailWeight}}克
						</view>
						<view class="demo-tag">
							<view class="demo-tag-owner">
								库存：
							</view>
							<view class="demo-tag-text">
								{{item.orderDetailRepertory}}
							</view>
						</view>
					<!-- <view class="demo-shop">
						{{item.shop}}
					</view> -->
						<u-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.orderDetailId)"></u-icon>
					</view>
				</view>
	
		<!-- <u-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="addRandomData"></u-loadmore> -->
	</view>
</template>

<script>
	import request from '../../../utils/request.js'
	export default {
		data() {
			return {
				loadStatus: 'loadmore',
				flowList: [],
				userid:undefined,
				list: [],
				form:{},
				storeId:{}
			}
		},
		onLoad() {
			// this.addRandomData();
		},
		onReachBottom() {
		},
		// created() {
			
		// },
		onLoad() {
			this.fourQueryShop()
		},
		methods: {
			// addRandomData() {
			// 	for(let i = 0; i < this.list.length; i++) {
			// 		let index = this.$u.random(0, this.list.length - 1);
			// 		// 先转成字符串再转成对象，避免数组对象引用导致数据混乱
			// 		let item = JSON.parse(JSON.stringify(this.list[index]))
			// 		item.id = this.$u.guid();
			// 		this.flowList.push(item);
			// 	}
			// },
			remove(id) {
				console.log(id)
				// this.$refs.uWaterfall.remove(id);
			},
			clear() {
				this.$refs.uWaterfall.clear();
			},
			fourQueryShop(){
				uni.getStorage({
					key: 'beforeUser',
					success: (res) => {
						this.userid = res.data.beforeUserId		
					},
					})
				request({
					url: '/detail/bgs/order-detail/fourOpenShop?id='+this.userid,
					method: 'Get',
					success: (res) => {
						console.log(res.data.data.data) 
						this.list = res.data.data.data
						this.storeId = res.data.data.data[0].storeId
					}
				})
			},
			/* 上架商品 */
			soldshop(){
				uni.navigateTo({
					url:'../addstuff/addstuff?id='+this.storeId
				})
			},
			skipDetail(id){
				console.log(id)
				uni.navigateTo({
					url:'../../product/product?id='+id
				})
			}
		}
	}
</script>

<style>
	/* page不能写带scope的style标签中，否则无效 */
	page {
		background-color: rgb(240, 240, 240);
	}
</style>

<style lang="scss" scoped>
	.demo-warter {
		border-radius: 8px;
		margin: 5px;
		background-color: #ffffff;
		padding: 8px;
		position: relative;
	}
	
	.u-close {
		position: absolute;
		top: 32rpx;
		right: 32rpx;
	}
	
	.demo-image {
		width: 100%;
		border-radius: 4px;
	}
	
	.demo-title {
		font-size: 30rpx;
		margin-top: 5px;
		color: $u-main-color;
	}
	
	.demo-tag {
		display: flex;
		margin-top: 5px;
	}
	
	.demo-tag-owner {
		background-color: $u-type-error;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}
	
	.demo-tag-text {
		border: 1px solid $u-type-primary;
		color: $u-type-primary;
		margin-left: 10px;
		border-radius: 50rpx;
		line-height: 1;
		padding: 4rpx 14rpx;
		display: flex;
		align-items: center;
		border-radius: 50rpx;
		font-size: 20rpx;
	}
	
	.demo-price {
		font-size: 30rpx;
		color: $u-type-error;
		margin-top: 5px;
	}
	
	.demo-shop {
		font-size: 22rpx;
		color: $u-tips-color;
		margin-top: 5px;
	}
</style>